﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections;
using ERMap;

namespace PhoneBook.Group
{
    public class BranchOffice
    {
        public static DataSet list(string groupid)
        {
            Hashtable keys = new Hashtable();
            keys["groupid"] = groupid;
            return ERMapHelper.getdata("b_branchoffice", keys);
        }

        public static DataSet list(string groupid, string boid)
        {
            Hashtable keys = new Hashtable();
            keys["groupid"] = groupid;
            keys["id"] = boid; 
            return ERMapHelper.getdata("b_branchoffice", keys);
        }

        public static void del(string boid)
        {
            Hashtable keys = new Hashtable();
            keys["id"] = boid;
            ERMapHelper.delmodel("b_branchoffice", keys);
        }

        public static void add(Hashtable branchoffice)
        {
            branchoffice["id"] = "";
            ERMapHelper.setmodel("b_branchoffice", "id", branchoffice);
        }

        public static Hashtable get(string id)
        {
            Hashtable keys = new Hashtable();
            keys["id"] = id;
            return ERMapHelper.getmodel("b_branchoffice", keys);
        }

        public static int? GetIdByName(String boname)
        {
            Hashtable keys = new Hashtable();

            keys["boname"] = boname;

            Hashtable bo = ERMapHelper.getmodel("b_branchoffice", keys);

            if (!(bo == null && bo.Count > 0))
            {
                return (int)bo["id"];
            }

            return null;
        }

        public static void edit(Hashtable branchoffice)
        {
            ERMapHelper.setmodel("b_branchoffice", "id", branchoffice);
        }

        public static string getmaxid()
        {
            return ERMapHelper.maxid("b_branchoffice", "id");
        }
    }
}
